# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=sthttpd
_pkgname=thttpd
pkgver=2.27.1
pkgrel=1
pkgdesc="Supported fork of the thttpd web server"
url="https://github.com/blueness/sthttpd"
arch="all"
license="custom:BSD"
options="!check"
makedepends="automake autoconf libtool"
depends="!thttpd"
install="$pkgname.pre-install"
subpackages="$pkgname-doc $pkgname-openrc"
source="$pkgname-$pkgver.tar.gz::https://github.com/blueness/sthttpd/archive/v$pkgver.tar.gz
	$_pkgname.initd
	$_pkgname.confd
	$pkgname.conf
	$_pkgname.logrotated
	sthttpd-webgroup.patch
	sthttpd-makeweb-notsuid.patch
	libhttpd-c.patch
	"

prepare() {
	default_prepare
	sh autogen.sh
}

build() {
	export WEBDIR=/var/www/http
	export WEBGROUP=www-data
	./configure --prefix=/usr \
		--bindir=/usr/sbin \
		--mandir=/usr/share/man
	make
}

package() {
	make DESTDIR="$pkgdir" install
	install -m755 -D "$srcdir"/$_pkgname.initd \
		"$pkgdir"/etc/init.d/$_pkgname
	install -m644 -D "$srcdir"/$_pkgname.confd \
		"$pkgdir"/etc/conf.d/$_pkgname
	install -m644 -D "$srcdir"/$pkgname.conf \
		"$pkgdir"/etc/$pkgname.conf
	install -m644 -D "$srcdir"/$_pkgname.logrotated \
		"$pkgdir"/etc/logrotate.d/thttpd
	install -d "$pkgdir"/var/log/thttpd

	mkdir -p "$pkgdir/usr/share/doc/$pkgname"
	cat > $pkgdir/usr/share/doc/$pkgname/README.alpine <<EOF
	To use makeweb, please set suid to makeweb binary with:
	-------------------------------------------------------
	chmod 2755 /usr/sbin/makeweb
EOF
	
}
sha512sums="
5d42e32652eb2310c7379d2c4373ad8f54b33bd7c2b444f06d1756eb4ed296774ce3144d91bbba85c6ad604e575128dc7199b797dc8d1b4849b0249054ba5d24  sthttpd-2.27.1.tar.gz
bc7416986e135ade401721708060b94ce3bb885a3aa40893d68abc1b305c13609e086fbb48f8db11656902c294bf558a81814013ef3a14d73f0c5f0df0decb7d  thttpd.initd
f51d7ccfb5fc07642329f2faa4e77382be75ab20f7efcd4b0c3f51b8a370e887a063069ae3c38268b91b1ca92dd0a35675ad8e3a52ce01f86d605eeb00a0f43a  thttpd.confd
fa5e870bba6125d03f16b5850da295ae8e19b9f3839b7edd2329bac69e4fbaf8fadc559da5003b46bc65be3b74a26a8c29a7c65ce3c513134d6bfcadcf51f8f5  sthttpd.conf
c61eb7913929bbd30088721ea85f162060209850aa7774fb7b9417a06b6aab5c97f1949ed002416a7f2e75da85cd071682acbdfb93fe3e9fd2c8c8757f18a522  thttpd.logrotated
e956715d31a8a5f974a566fb8d2018d8c2d9cf074fb45c32c78b231ebbd7b84a4b3f1fafcd77b9230e5c177fec5e22990d82372f068c945891799b55ebc8f359  sthttpd-webgroup.patch
e32582f84d7e44cf2e60000600aa3e46e03d7ed660894bb4db016669d278a75329b7ee300e4b8dcd337209833a1ba62db9fb46077495cb0d73668cee266304eb  sthttpd-makeweb-notsuid.patch
a320432f5b3c186bd1c593f57042996f10b49dbaa45cbed3c27d6b88cb644af220e9216dea01a6723f68b61f237dc7314c0ea38121d78e522a436794e1d1cb87  libhttpd-c.patch
"
